home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / utility / ffe101.zip / EXEC.SWG / 0003_MZEXE.pas < prev    next >
Pascal/Delphi Source File  |  1996-09-03  |  6KB  |  126 lines

  1. --------E-MZ EXE----------------------------
  2.  
  3. The  old  EXE files are the EXE  files executed directly by MS-DOS. They
  4. were a major improvement over the old 64K COM files, since EXE files can
  5. span  multiple segments. An EXE file  consists of three different parts,
  6. the  header,  the  relocation table and  the  binary code. The header is
  7. expanded  by  a lot of programs  to store their copyright information in
  8. the  executable, some extensions are documented below. The format of the
  9. header is as follows :
  10.  
  11. OFFSET              Count TYPE   Description
  12. 0000h                   2 char   ID='MZ'
  13.                                  ID='ZM'
  14. 0002h                   1 word   Number of bytes in last 512-byte page
  15.                                  of executable
  16. 0004h                   1 word   Total number of 512-byte pages in executable
  17.                                  (including the last page)
  18. 0006h                   1 word   Number of relocation entries
  19. 0008h                   1 word   Header size in paragraphs
  20. 000Ah                   1 word   Minimum paragraphs of memory allocated in
  21.                                  addition to the code size
  22. 000Ch                   1 word   Maximum number of paragraphs allocated in
  23.                                  addition to the code size
  24. 000Eh                   1 word   Initial SS relative to start of executable
  25. 0010h                   1 word   Initial SP
  26. 0012h                   1 word   Checksum (or 0) of executable
  27. 0014h                   1 dword  CS:IP relative to start of executable
  28.                                  (entry point)
  29. 0018h                   1 word   Offset of relocation table;
  30.                                  40h for new-(NE,LE,LX,W3,PE etc.) executable
  31. 001Ah                   1 word   Overlay number (0h = main program)
  32.  
  33. Following  are  the header expansions by  some other prorams like TLink,
  34. LZExe  and  other linkers, encryptors  and  compressors; all offsets are
  35. relative to the start of the whole header :
  36.  
  37. ---new executable
  38. OFFSET              Count TYPE   Description
  39. 001Ch                   4 byte   ????
  40. 0020h                   1 word   Behaviour bits ??
  41. 0022h                  26 byte   reserved (0)
  42. 003Ch                   1 dword  Offset of new executable header from start of
  43.                                  file (or 0 if plain MZ executable)
  44.  
  45. ---Borland TLINK
  46. OFFSET              Count TYPE   Description
  47. 001Ch                   2 byte   ?? (apparently always 01h 00h)
  48. 001Eh                   1 byte   ID=0FBh
  49. 001Fh                   1 byte   TLink version, major in high nybble
  50. 0020h                   2 byte   ??
  51.  
  52. ---old ARJ self-extracting archive
  53. OFFSET              Count TYPE   Description
  54. 001Ch                   4 char   ID='RJSX' (older versions)
  55.                                  new signature is 'aRJsf'" in the first 1000
  56.                                  bytes of the file)
  57. ---LZEXE compressed executable
  58. OFFSET              Count TYPE   Description
  59. 001Ch                   2 char   ID='LZ'
  60. 001Eh                   2 char   Version number :
  61.                                   '09' - LZExe 0.90
  62.                                   '91' - LZExe 0.91
  63. ---PKLITE compressed executable
  64. OFFSET              Count TYPE   Description
  65. 001Ch                   1 byte   Minor version number
  66. 001Dh                   1 byte   Bit mapped :
  67.                                  0-3 - major version
  68.                                    4 - Extra compression
  69.                                    5 - Multi-segment file
  70. 001Eh                   6 char   ID='PKLITE'
  71. ---LHarc 1.x self-extracting archive
  72. OFFSET              Count TYPE   Description
  73. 001Ch                   4 byte   unused???
  74. 0020h                   3 byte   Jump to start of extraction code
  75. 0023h                   2 byte   ???
  76. 0025h                  12 char   ID='LHarc's SFX '
  77. --LHA 2.x self-extracting archive
  78. OFFSET              Count TYPE   Description
  79. 001Ch                   8 byte   ???
  80. 0024h                  10 char   ID='LHa's SFX '
  81.                                  For version 2.10
  82.                                  ID='LHA's SFX ' (v2.13)
  83.                                  For version 2.13
  84. ---LH self-extracting archive
  85. OFFSET              Count TYPE   Description
  86. 001Ch                   8 byte   ???
  87. 0024h                   8 byte   ID='LH's SFX '
  88. ---TopSpeed C 3.0 CRUNCH compressed file
  89. OFFSET              Count TYPE   Description
  90. 001Ch                   1 dword  ID=018A0001h
  91. 0020h                   1 word   ID=1565h
  92. ---PKARC 3.5 self-extracting archive
  93. OFFSET              Count TYPE   Description
  94. 001Ch                   1 dword  ID=00020001h
  95. 0020h                   1 word   ID=0700h
  96. ---BSA (Soviet archiver) self-extracting archive
  97. OFFSET              Count TYPE   Description
  98. 001Ch                   1 word   ID=000Fh
  99. 001Eh                   1 byte   ID=A7h
  100. ---LARC self-extracting archive
  101. OFFSET              Count TYPE   Description
  102. 001Ch                   4 byte   ???
  103. 0020h                  11 byte   ID='SFX by LARC '
  104.  
  105. After  the header, there follow the  relocation items, which are used to
  106. span multpile segments. The relocation items have the following format :
  107.  
  108. OFFSET              Count TYPE   Description
  109. 0000h                   1 word   Offset within segment
  110. 0002h                   1 word   Segment of relocation
  111.  
  112. To  get  the  position of the relocation  within  the  file, you have to
  113. compute  the physical adress from the segment:offset pair, which is done
  114. by  multiplying the segment by 16 and  adding the offset and then adding
  115. the  offset of the binary start. Note that the raw binary code starts on
  116. a  paragraph  boundary  within  the  executable  file.  All segments are
  117. relative  to the start of the executable  in memory, and this value must
  118. be added to every segment if relocation is done manually.
  119.  
  120. EXTENSION:EXE,OVR,OVL
  121. OCCURENCES:PC
  122. PROGRAMS:MS-DOS
  123. REFERENCE:Ralf Brown's Interrupt List
  124. SEE ALSO:COM,EXE,NE EXE
  125.  
  126.